<?php
/**
 * @author zhangrui
 */

namespace App\Common\RabbitMQ;

/**
 * MQ发布者
 * Class AbstractPublisher
 * @package App\Common\RabbitMQ
 */
class AbstractPublisher extends AbstractAMQP
{
    /** @var null 发布路由 */
    protected $routingKey = null;

    /** @var int 发布标志位 */
    protected $pubFlags = AMQP_NOPARAM;

    /**
     * 发布属性
     * @var array
     * 可用键名
     * content_type
     * content_encoding
     * message_id
     * user_id
     * app_id
     * delivery_mode
     * priority
     * timestamp
     * expiration
     * type
     * reply_to
     * headers
     */
    protected $attributes = ['delivery_mode' => AMQP_DURABLE];

    /**
     * AbstractPublisher constructor.
     * @param bool $persistent 使用持久连接
     * @throws \AMQPChannelException
     * @throws \AMQPConnectionException
     * @throws \AMQPExchangeException
     */
    public function __construct(bool $persistent = false)
    {
        parent::__construct($persistent);
    }

    public function getRoutingKey()
    {
        return $this->routingKey;
    }

    public function getPubFlags()
    {
        return $this->pubFlags;
    }

    public function getAttributes()
    {
        return $this->attributes;
    }
}
